package com.atguigu.springboot04web.controller;


import com.atguigu.springboot04web.exception.UserNotExistException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

@Controller
public class HelloController {


    @RequestMapping("/hello")
    public String hello(@RequestParam("user") String user) {
        if ((user.equals("aaa"))) {
            throw new UserNotExistException();
        }
        return "hello";
    }


    @RequestMapping("/success")
    public String success(Map<String, Object> map) {
        map.put("hello", "你好");
        map.put("users", Arrays.asList("zhangsan", "lisi", "王五"));
        map.put("he", "<h1>他</h1>");
        return "success";
    }
}
